package net.stogi.unicore.beyond.ui.client.taskrunner.runnermenu;

import net.stogi.common.mvp.core.behavior.Behavior;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Composite;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;

class RunnerMenuWidget extends Composite implements RunnerMenuView {

	private final ContentPanel mainPanel = new ContentPanel();

	private final Button openTaskButton = new Button();
	
	public RunnerMenuWidget() {
		initComposite();
		initI18n();
		initLayout();
		initComponent(mainPanel);
	}

	@Override
	public void setOpenTaskBehavior(final Behavior behavior) {
		openTaskButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				behavior.behave();
			}
		});
	}

	private void initComposite() {
		mainPanel.setFrame(true);
		openTaskButton.setWidth("100%");
	}

	private void initI18n() {
		mainPanel.setHeading("Runner Menu");
		openTaskButton.setText("Open Task");
	}

	private void initLayout() {
		mainPanel.add(openTaskButton);
	}
}
